<template>
  <div>
    <div class="header-container">
      <div class="header-title">
        <img src="../assets/image/title-icon.png" />
        <div>统一登录平台</div>
      </div>
      <div class="control-container">
        <div class="manger">
          <img
            title="后台管理"
            @click="handleMangerclick"
            src="../assets//image/manager.png"
          />
        </div>
        <div class="interval-bar">|</div>
        <div class="user-info"><UserInfo /></div>
      </div>
    </div>
    <div class="client-container">
      <div
        v-for="item in clientArr"
        :key="item.id"
        class="client-item-container"
        @click="handleClientClick(item)"
      >
        <div class="client-img-container">
          <img src="../assets//image/app.png" />
        </div>
        <div class="client-title">
          {{ item.name }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { GetUserClients, GetCode } from "../api/Authentication";
import UserInfo from "../components/UserInfo.vue";
export default {
  data() {
    return {
      clientArr: "",
    };
  },
  components: {
    UserInfo,
  },
  name: "GuidePage",
  methods: {
    getUserClients() {
      GetUserClients().then((result) => {
        console.log(result);
        this.clientArr = result.data;
      });
    },
    handleClientClick(item) {
      GetCode().then((result) => {
        let code = result.data;
        let url = item.url + "?code=" + code;
        window.open(url, "_blank");
      });
    },
    handleMangerclick() {
      window.open("/Home/StatisticsPage", "_blank");
    },
  },
  mounted() {
    this.getUserClients();
  },
};
</script>

<style scoped>
.client-item-container {
  margin: 5px;
  display: inline-block;
  cursor: pointer;
  margin-right: 3vw;
}
.header-container {
  display: flex;
  flex-direction: row;
  margin-right: auto;
  height: 8vh;
  background-color: rgb(41, 89, 244);
}
.control-container {
  display: flex;
  flex-direction: row;
  margin-left: auto;
}
.control-container > div {
  display: flex;
  align-items: center;
}
.interval-bar {
  margin-left: 20px;
  margin-right: 20px;
  color: white;
}
.user-info {
  margin-right: 40px;
}
.manger > img {
  width: 40px;
  height: 40px;
  cursor: pointer;
}
.header-title {
  display: flex;
  flex-direction: row;
  align-items: center;
  color: white;
  font-size: 26px;
  font-family: "Arial";
  font-weight: bold;
}
.header-title > img {
  width: 40px;
  height: 40px;
  margin-left: 20px;
  margin-right: 20px;
}
.client-container {
  width: 80vw;
  min-height: 87vh;
  margin-left: 10vw;
  margin-top: 5vh;
}

.client-img-container {
  width: 10vw;
  height: 10vw;

  border-radius: 5px;
  display: flex;
  justify-content: center; /* 水平居中 */
  align-items: center; /* 垂直居中 */
  box-shadow: 2px 2px 2px 2px rgba(0, 0, 0, 0.5);
}
.client-title {
  text-align: center;
  margin-top: 2vh;
}
</style>
